package org.realteam.hibernate.test.model.em;

import java.io.Serializable;

public enum Gender implements Serializable{
	
	MALE("男", 1),
	
	FEMALE("女", 2),
	
	OTHER("保密", 3);
	
	private String name;
	
	private int value;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getValue() {
		return value;
	}

	public void setValue(int value) {
		this.value = value;
	}
	
	private Gender(String name, int value) {
		this.name = name;
		this.value = value;
	}
	
	public static Gender getGender(int value) {
		for (Gender gender : Gender.values()) {
			if(gender.value == value)
				return gender;
		}
		
		return null;
	}
	
	@Override
	public String toString() {
		return "[" + this.name 
					+ "=" + this.value + "]";
	}
}
